﻿using Lightworks.Core.Constant;
using Lightworks.System.Dto;
using Lightworks.System.Models;
using Lightworks.System.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Lightworks.Api.Controllers
{
    
    [ApiController]
    [Route("api/")]
    public class AuthController : ApiBaseController
    {
        IAuthService authService;
        public AuthController(IAuthService authService) 
        {
            this.authService = authService;
        }

        [HttpPost("token")]
        public ApiResult Login(LoginReq req)
        {
            var result = authService.Login(req.Username, req.Password);
            if(result == null) 
            {
                return Fail400(message:"错误的用户名或密码");
            }
            return Ok(data:result);
        }
    }
    
}
